#include <stdio.h>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <string.h>
using namespace std;

#define TRACE(x...)  
#define PRINT(x...) TRACE(printf(x))

#define rep(i,n) for (int i=0; i<n; i++)
#define inter(i,a,b) for (int i=a; i<b; i++)

#define oo 0x3f3f3f3f

#define x first
#define c second
#define mp make_pair

int n;
pair<int, int> m[3010];
long long int cost[3010];
long long int dist[3010][3010];
int lastPos;
long long int best;

int main() {
	scanf("%d", &n);
	rep(i,n) scanf("%d %d", &m[i].x, &m[i].c);
	sort(m, m+n);

	TRACE(
		printf("List of marbles\n");
		rep(i,n) printf("%d %d\n", m[i].x, m[i].c);
		printf("\n");
	)

	dist[0][0]=0;
	rep(i,n) dist[i][i]=0;

	rep(i,n) rep(j,n) {
		if (j<=i) continue;
		dist[i][j]=dist[i][j-1]+(m[j].x-m[i].x);
	}
	
	TRACE(
		printf("Distancias\n");
		rep(i,n) {
			rep(j,n) printf("%lld ", dist[i][j]);
			printf("\n");
		}
		printf("\n");
	)

	cost[0]=m[0].c;
	lastPos=0;

	rep(i,n) {
		if (!i) continue;
		PRINT("Para %d:\n", i);
		cost[i]=m[i].c+cost[0]+dist[0][i];		

		rep(j, i) {
			PRINT("Dist from %d to %d is: %lld\n", j, i-1, dist[j][i-1]);
			PRINT("cost if last pinned is %d: %lld\n", j, cost[j]+dist[j][i-1]+m[i].c);	
			cost[i]=min(cost[i], cost[j]+dist[j][i-1]+m[i].c);
		}

		PRINT("\n");
	}

	TRACE(
		printf("Custo sem distancias\n");
		rep(i,n) printf("%lld ", cost[i]);
		printf("\n");

		printf("Custo com distancias\n");
		rep(i,n) printf("%lld ", cost[i]+dist[i][n-1]);
		printf("\n");
	)

	best=cost[0]+dist[0][n-1];

	rep(i,n) best=min(best, cost[i]+dist[i][n-1]);
	printf("%lld\n", best);

	return 0;
}
